package com.wzz.common.security;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class CryptoUtils {
    public static String getMD5(String val) throws NoSuchAlgorithmException {
      return crypto("MD5",val.getBytes());
    }
  
    public static String getSHA(String val) throws NoSuchAlgorithmException {
      return crypto("SHA-1",val.getBytes());
    }
    
    private static String crypto(String type,byte[] val) throws NoSuchAlgorithmException{
      MessageDigest sha = MessageDigest.getInstance("SHA-1");
      sha.update(val);
      return CommonUtils.getString(sha.digest());
    }
  
}
